import { getSelectCityList } from '@/servers/api/base';
import { filterCity } from '@/utils';
import { getLocale } from '@umijs/max';
import { Cascader } from 'antd';
import { useEffect, useState } from 'react';

const FromCity: React.FC<IBuildForm.Params> = (props) => {
    const lang = getLocale();
    const [options, setoptions] = useState([]);
    function getList() {
        getSelectCityList({
            country: lang === 'zh-CN' ? '0' : '1',
            pid: 0,
            is_port:1
        }).then((res) => {
            setoptions(res.data);
        });
    }
    useEffect(() => {
        getList();
    }, []);
    return (
        <Cascader
            {...props}
            options={options}
            placeholder={props.placeholder}
            showSearch={{ filterCity }}
        />
    );
};
export default FromCity;
